﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MuseLibrary.Packets
{
    public static class PacketFactory
    {
        public static Packet MakePacket(int b)
        {
            if (b == 255)
                return new SynchronisationPacket();

            var nibble = (PacketType)(b >> 4);
            switch (nibble)
            {
                case PacketType.UncompressedEeg:
                    return new UncompressedEegPacket();
                case PacketType.CompressedEeg:
                    return new CompressedEegPacket();
                case PacketType.ErrorFlags:
                    return new ErrorPacket();
                case PacketType.Accelerometer:
                    return new AccelerometerPacket();
                case PacketType.DrlRef:
                    return new DrlRefPacket();
                case PacketType.Battery:
                    return new BatteryPacket();
            }

            return null;
        }
    }
}
